package com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.view;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.bean.DevicesCustomConfigurationBean;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.bean.DevicesManagerBean;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.custom_view.MyRoundRectImageView;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.contract.IDevicesManagerPagerCantract;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.persenter.DevicesManagerPagerPersenter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.utils.VirtualButtonsUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/8/9.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class DevicesManagerPagerActivity extends AppCompatActivity implements IDevicesManagerPagerCantract.IDevicesManagerPagerView {


    @BindView(R.id.activity_devices_manager_iv_head)
    MyRoundRectImageView activityDevicesManagerIvHead;
    @BindView(R.id.activity_devices_manager_tv_name)
    TextView activityDevicesManagerTvName;
    @BindView(R.id.activity_devices_manager_progressBar)
    ProgressBar activityDevicesManagerProgressBar;
    @BindView(R.id.activity_devices_manager_tv_progressBar)
    TextView activityDevicesManagerTvProgressBar;
    @BindView(R.id.activity_devices_manager_tv_line)
    TextView activityDevicesManagerTvLine;
    @BindView(R.id.activity_devices_manager_iv_change)
    ImageView activityDevicesManagerIvChange;
    @BindView(R.id.activity_devices_manager_re_2)
    RelativeLayout activityDevicesManagerRe2;
    @BindView(R.id.activity_devices_manager_tv_info_name)
    TextView activityDevicesManagerTvInfoName;
    @BindView(R.id.activity_devices_manager_tv_info_type)
    TextView activityDevicesManagerTvInfoType;
    @BindView(R.id.activity_devices_manager_tv_info_mouse_total)
    TextView activityDevicesManagerTvInfoMouseTotal;
    @BindView(R.id.activity_devices_manager_tv_info_storage)
    TextView activityDevicesManagerTvInfoStorage;
    @BindView(R.id.activity_devices_manager_tv_manager_recy)
    RecyclerView activityDevicesManagerTvManagerRecy;
    @BindView(R.id.activity_devices_manager_tv_manager)
    TextView activityDevicesManagerTvManager;
    @BindView(R.id.activity_devices_manager_tv_manager_line_2)
    TextView activityDevicesManagerTvManagerLine2;
    @BindView(R.id.activity_devices_manager_iv_back)
    ImageView activityDevicesManagerIvBack;

    private DevicesManagerPagerPersenter devicesManagerPagerPersenter = new DevicesManagerPagerPersenter(this);
    private DevicesManagerBean device_attrib;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        VirtualButtonsUtils.hideNavKey(this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_devices_manager);
        ButterKnife.bind(this);

        device_attrib = (DevicesManagerBean) getIntent().getSerializableExtra("device_attrib");
        devicesManagerPagerPersenter.initView(activityDevicesManagerTvManagerRecy, this);
    }

    @OnClick({R.id.activity_devices_manager_iv_head, R.id.activity_devices_manager_iv_change,
            R.id.activity_devices_manager_tv_manager,R.id.activity_devices_manager_iv_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_devices_manager_iv_head:
                devicesManagerPagerPersenter.onClickedHeadImageView();
                break;
            case R.id.activity_devices_manager_iv_change:
                devicesManagerPagerPersenter.onClickedChangeImageView();
                break;
            case R.id.activity_devices_manager_tv_manager:
                devicesManagerPagerPersenter.onClickedManagerTextView();
                break;
            case R.id.activity_devices_manager_iv_back:
                devicesManagerPagerPersenter.onClickedBackImageView();
                break;
        }
    }


    @Override
    protected void onStart() {
        super.onStart();
        devicesManagerPagerPersenter.loadDate(this, device_attrib.getId());
        devicesManagerPagerPersenter.initDate(this, device_attrib);
    }

    @Override
    public void setDeviceName(String name) {
        activityDevicesManagerTvInfoName.setText(name);
    }

    @Override
    public void setDeviceType(String type) {
        activityDevicesManagerTvInfoType.setText(type);

    }

    @Override
    public void setDeviceMouseTotal(String mouseTotal) {
        activityDevicesManagerTvInfoMouseTotal.setText(mouseTotal);
    }

    @Override
    public void setDeviceStorage(String storage) {
        activityDevicesManagerTvInfoStorage.setText(storage);
    }

    @Override
    public void toFileSettingPager(int postion) {
        Intent intent =   new Intent(this,FileSetConfigActivity.class);
        intent.putExtra("devices_config_info_postion", postion);
        intent.putExtra("devices_config_info_id", device_attrib.getId());
        startActivity(intent);
    }

    @SuppressLint("LongLogTag")
    @Override
    public void toManageProfilesPager() {
        Intent intent = new Intent(this,ManageProfilesPagerActivity.class);
        intent.putExtra("file_device_attrib",device_attrib.getId());
        startActivity(intent);
    }

    @Override
    public void toMettingName(String name) {
        activityDevicesManagerTvName.setText(name);
    }

    @Override
    public void toback() {
        finish();

    }

    @Override
    public void setMyProgress(int progress) {
        activityDevicesManagerProgressBar.setProgress(progress);
    }

    @Override
    public void setProgressContent(String progress) {
        activityDevicesManagerTvProgressBar.setText(progress);
    }
}
